<?php

namespace App\Models\Form;
class ActivityForm extends RootForm
{
    //
    public $typeid;
    public $title;
    public array $conf;
    public $province;
    public $city;
    public $county;
    public $area;
    public $school;

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        parent::validate([
            'typeid' => $this->typeid,
            'title' => $this->title,
            'province' => $this->province,
            'city' => $this->city,
            'county' => $this->county,
            'area' => $this->area,
            'school' => $this->school
        ], [
            "typeid" => "required",
            "title" => "required",
            "province" => "required",
            "city" => "required",
            "county" => "required",
            "area" => "required",
            "school" => "required",
        ], [
            "required" => ":attribute验证失败"
        ], [
            "typeid" => "活动类型",
            "title" => "活动标题",
            "province" => "省份",
            "city" => "城市",
            "county" => "区县",
            "area" => "街道",
            "school" => "机构",
        ]);
    }

    public function getDBData()
    {
        return [
            'typeid' => $this->typeid,
            'title' => $this->title,
            'conf' => json_encode(empty($this->conf) ? [] : $this->conf),
            'province' => $this->province,
            'city' => $this->city,
            'county' => $this->county,
            'area' => $this->area,
            'school' => $this->school
        ];
    }
}
